{% extends 'base.html' %}

{% block title %}飞牛媒体库 - SkitPanel 短剧管理面板{% endblock %}

{% block styles %}
    <link rel="stylesheet" href="{{ url_for('static', filename='css/fnos_media.css') }}">
{% endblock %}

{% block content %}
<div class="container mx-auto p-4">
    <div class="bg-white rounded-xl shadow-lg p-6">
        <div class="mb-6">
            <h1 class="text-2xl font-bold text-dark">飞牛媒体库</h1>
            <p class="text-gray-500 mt-1">浏览和管理飞牛媒体库中的媒体资源</p>
        </div>

        <!-- 媒体库列表区域 -->
        <div class="mb-8">
            <h2 class="text-xl font-semibold text-dark mb-4">媒体库列表</h2>
            <div id="library-list" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
                <!-- 媒体库项将通过JavaScript动态添加 -->
                <div class="col-span-full py-8 text-center text-gray-500">
                    <i class="fa fa-refresh fa-spin text-xl mb-2"></i>
                    <p>正在加载媒体库...</p>
                </div>
            </div>
        </div>

        <!-- 媒体条目区域 -->
        <div id="media-content" class="hidden">
            <div class="flex justify-between items-center mb-4">
                <h2 class="text-xl font-semibold text-dark" id="selected-library-name">媒体内容</h2>
                <button id="back-to-libraries" class="px-4 py-2 bg-gray-100 text-gray-700 rounded-md hover:bg-gray-200 transition-colors">
                    <i class="fa fa-arrow-left mr-1"></i> 返回媒体库列表
                </button>
            </div>
            
            <div id="media-list" class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4">
                <!-- 媒体条目将通过JavaScript动态添加 -->
            </div>
        </div>

        <!-- 媒体详情弹窗 -->
        <div id="media-detail-modal" class="fixed inset-0 bg-black/70 flex items-center justify-center z-50 hidden">
            <div class="bg-white rounded-xl shadow-xl max-w-4xl w-full max-h-[90vh] overflow-auto">
                <div class="p-6">
                    <div class="flex justify-between items-center mb-4">
                        <h3 class="text-xl font-bold text-dark" id="detail-title">媒体详情</h3>
                        <button id="close-detail-modal" class="text-gray-500 hover:text-gray-700">
                            <i class="fa fa-times text-xl"></i>
                        </button>
                    </div>
                    <div id="detail-content" class="grid grid-cols-1 md:grid-cols-3 gap-6">
                        <!-- 海报 -->
                        <div class="md:col-span-1">
                            <img id="detail-poster" src="" alt="媒体海报" class="rounded-lg w-full h-auto">
                        </div>
                        <!-- 详情信息 -->
                        <div class="md:col-span-2 space-y-4">
                            <div class="space-y-2">
                                <h4 class="text-lg font-semibold" id="detail-title-full"></h4>
                                <div class="text-sm text-gray-600" id="detail-info"></div>
                            </div>
                            <div class="space-y-2">
                                <h5 class="font-medium">剧情简介</h5>
                                <p id="detail-overview" class="text-sm text-gray-700 line-clamp-6 hover:line-clamp-none transition-all duration-300"></p>
                            </div>
                            <div class="grid grid-cols-2 gap-4 text-sm">
                                <div class="space-y-1">
                                    <span class="text-gray-500">类型:</span>
                                    <span id="detail-type"></span>
                                </div>
                                <div class="space-y-1">
                                    <span class="text-gray-500">语言:</span>
                                    <span id="detail-language"></span>
                                </div>
                                <div class="space-y-1">
                                    <span class="text-gray-500">时长:</span>
                                    <span id="detail-runtime"></span>
                                </div>
                                <div class="space-y-1">
                                    <span class="text-gray-500">发行日期:</span>
                                    <span id="detail-release-date"></span>
                                </div>
                                <div class="space-y-1">
                                    <span class="text-gray-500">评分:</span>
                                    <span id="detail-rating"></span>
                                </div>
                                <div class="space-y-1">
                                    <span class="text-gray-500">所属媒体库:</span>
                                    <span id="detail-library"></span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block scripts %}
    <script src="{{ url_for('static', filename='js/fnos_media.js') }}"></script>
{% endblock %}